00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _dae_solver_hpp_
00021 #define _dae_solver_hpp_
00022
00023 #include <gridpack/math/dae_solver_implementation.hpp>
00024
00025 namespace gridpack {
00026 namespace math {
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 template <typename T, typename I = int>
00037 class DAESolverT
00038 : public DAESolverInterface<T, I>,
00039 public parallel::WrappedDistributed,
00040 public utility::WrappedConfigurable,
00041 private utility::Uncopyable
00042 {
00043 public:
00044
00045 typedef typename DAESolverInterface<T, I>::VectorType VectorType;
00046 typedef typename DAESolverInterface<T, I>::MatrixType MatrixType;
00047 typedef typename DAESolverInterface<T, I>::JacobianBuilder JacobianBuilder;
00048 typedef typename DAESolverInterface<T, I>::FunctionBuilder FunctionBuilder;
00049 typedef typename DAESolverInterface<T, I>::StepFunction StepFunction;
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 DAESolverT(const parallel::Communicator& comm,
00064 const int local_size,
00065 JacobianBuilder& jbuilder,
00066 FunctionBuilder& fbuilder);
00067
00068
00069 ~DAESolverT(void)
00070 {}
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 void initialize(const double& t0,
00082 const double& deltat0,
00083 VectorType& x0)
00084 {
00085 p_impl->initialize(t0, deltat0, x0);
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 void solve(double& maxtime, int& maxsteps)
00104 {
00105 p_impl->solve(maxtime, maxsteps);
00106 }
00107
00108 protected:
00109
00110
00111 boost::scoped_ptr<DAESolverImplementation<T, I> > p_impl;
00112
00113
00114 void p_setImpl(DAESolverImplementation<T, I> *impl)
00115 {
00116 p_impl.reset(impl);
00117 p_setDistributed(p_impl.get());
00118 p_setConfigurable(p_impl.get());
00119 }
00120
00121
00122
00123 void p_initialize(const double& t0,
00124 const double& deltat0,
00125 VectorType& x0)
00126 {
00127 p_impl->initialize(t0, deltat0, x0);
00128 }
00129
00130
00131
00132 void p_solve(double& maxtime, int& maxsteps)
00133 {
00134 p_impl->solve(maxtime, maxsteps);
00135 }
00136
00137
00138 void p_preStep(StepFunction& f)
00139 {
00140 p_impl->preStep(f);
00141 }
00142
00143
00144 void p_postStep(StepFunction& f)
00145 {
00146 p_impl->postStep(f);
00147 }
00148 };
00149
00150 typedef DAESolverT<ComplexType> ComplexDAESolver;
00151 typedef DAESolverT<RealType> RealDAESolver;
00152 typedef ComplexDAESolver DAESolver;
00153
00154 }
00155 }
00156
00157 #endif